# from selenium import webdriver
# from selenium.webdriver import ActionChains
#
# driver = webdriver.Chrome()
# driver.get()
# element = driver.find_element()
#
# element.click()
# element.send_keys()
# driver.execute_script("window.scrollTo(0,document.body.scrollHeight);")

# 复杂动作 通过动作链对象来实现
# ActionChains(driver).click(element).perform()
# ActionChains(driver).click_and_hold(element).perform()
# ActionChains(driver).double_click(element).perform()
# ActionChains(driver).context_click(element).perform()


from selenium.webdriver.common.action_chains import ActionChains
from selenium import webdriver
import time

options = webdriver.ChromeOptions()
options.add_argument(r"--user-data-dir=C:\Users\Administrator\AppData\Local\Google\Chrome\User Data")
driver = webdriver.Chrome(options=options)
driver.get("https://www.douyin.com/?recommend=1")
driver.maximize_window()
time.sleep(15)

while True:
    video_ele = driver.find_element("xpath","//video[@autoplay]")
    ActionChains(driver).double_click(video_ele).perform() # 利用动作链双击点赞
    time.sleep(10)
    next_video_btn = driver.find_element("xpath","//div[@class='xgplayer-playswitch-next']")
    next_video_btn.click()
    time.sleep(5)